tools: libxl: Handle failure to create qemu dm logfile
authorIan Campbell <ian.campbell@citrix.com>
Mon, 13 Jul 2015 12:31:23 +0000 (13:31 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 15 Jul 2015 09:53:51 +0000 (10:53 +0100)
If libxl_create_logfile fails for some reason then
libxl__create_qemu_logfile previously just carried on and dereferenced
the uninitialised logfile.

Check for the error from libxl_create_logfile, which has already
logged for us.

This was reported as Debian bug #784880.

Reported-by: Russell Coker <russell@coker.com.au>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: 784880@bugs.debian.org
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl_dm.c

index ad434f05ef83837ab0c087b079d731ddac8482e5..8ed2d2ed1d0d192f06c9d0510b9f85f32ff9680b 100644 (file)
@@ -46,9 +46,11 @@ static const char *qemu_xen_path(libxl__gc *gc)
 static int libxl__create_qemu_logfile(libxl__gc *gc, char *name)
 {
     char *logfile;
-    int logfile_w;
+    int rc, logfile_w;
+
+    rc = libxl_create_logfile(CTX, name, &logfile);
+    if (rc) return rc;
 
-    libxl_create_logfile(CTX, name, &logfile);
     logfile_w = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644);
     free(logfile);